<?php
class CreatePosts extends CakeMigration {

/**
 * Migration description
 *
 * @var string
 * @access public
 */
	public $description = '';

/**
 * Actions to be performed
 *
 * @var array $migration
 * @access public
 */
	public $migration = array(
		'up' => array(
			'create_table' => array(
				'posts' => array(
					  'id' => array('type'    =>'integer',
										      'null'    => false,
													'key'			=> 'primary'),
						'title'	=> array('type' => 'string', 'null' => false),
						'description'	=> array('type' => 'text', 'null' => false),
						'content' => array('type' => 'text', 'null' => false),
						'tags' => array('type' => 'string'),
						'status' => array('type' => 'integer', 'null' => false, 'default' => 0),
						'type' => array('type' => 'integer', 'null' => false, 'default' => 0),
						'category_id' => array('type' => 'integer'),
						'slug' => array('type' => 'string', 'null' => false),
						'meta_keywords' => array('type' => 'string', 'null' => false),
						'meta_description' => array('type' => 'text', 'null' => false),

						'image' => array('type' => 'string', 'default' => null),
						'dir' => array('type' => 'string', 'default' => null),
						'mimetype' => array('type' => 'string', 'default' => null),
						'filesize' => array('type' => 'integer', 'default' => null),

						'created_at' => array('type' => 'timestamp', 'null' => false, 'default' => '0000-00-00 00:00:00'),
						'updated_at' => array('type' => 'timestamp', 'null' => false, 'default' => '0000-00-00 00:00:00'),
						'schedule_public_date' => array('type' => 'timestamp', 'null' => false, 'default' => '0000-00-00 00:00:00'),
						'created_by' => array('type' => 'integer'),
						'updated_by' => array('type' => 'integer'),
					  'indexes' => array(
					      'PRIMARY' => array(
					          'column' => 'id',
					          'unique' => 1),
								'SLUG_UNIQUE' => array(
										'column' => 'slug',
										'unique' => 1),
					  )
				)
			)
		),
		'down' => array(
			'drop_table' => array(
				'posts'
			),
		),
	);

/**
 * Before migration callback
 *
 * @param string $direction, up or down direction of migration process
 * @return boolean Should process continue
 * @access public
 */
	public function before($direction) {
		return true;
	}

/**
 * After migration callback
 *
 * @param string $direction, up or down direction of migration process
 * @return boolean Should process continue
 * @access public
 */
	public function after($direction) {
		return true;
	}
}
